package reflect;

import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Class cls=Class.forName("reflect.Person");
        Object o=cls.newInstance();

        //say(String message)
        Method method1=cls.getMethod("say", String.class);
        method1.invoke(o,"小伙过来！姨，给你说个话！！");

        //say(String message, int sum )

        Method method2=cls.getMethod("say", String.class,int .class);
        method2.invoke(o,"五百一次！！！绝对安全！！！",3);
    }

}
